package com.yunxi.controller.sto;

import com.yunxi.sto.pojo.StoVrfidHistoryVO;
import com.yunxi.sto.service.StoVrfidHistoryDubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yunxi.core.web.ResponseUtil;
import java.util.*;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 车辆RFID绑定历史 前端控制器
 * </p>
 *
 * @author caoYong
 * @since 2019-07-23
 */
@RestController
@RequestMapping("/admin/stoVrfidHistory")
@Api(tags = "sto:vrfidHistory", description = "车辆RFID绑定历史接口")
public class StoVrfidHistoryController {
    private static final Logger logger = LoggerFactory.getLogger(StoVrfidHistoryController.class);

    @Autowired
    StoVrfidHistoryDubboService stoVrfidHistoryDubboService;

    @GetMapping("/page")
    @ApiOperation(value = "查询分页")
    public ApiResult page(StoVrfidHistoryVO stoVrfidHistoryVO, Integer pageNum, Integer pageSize,@CurrentUser LoginInfo loginInfo) throws Exception {
        return ResponseUtil.ok(stoVrfidHistoryDubboService.findPageByVO(stoVrfidHistoryVO, pageNum, pageSize,loginInfo));
    }

    @GetMapping("/list")
    @ApiOperation(value = "查询列表")
    public ApiResult list(StoVrfidHistoryVO stoVrfidHistoryVO) throws Exception {
        return ResponseUtil.ok(stoVrfidHistoryDubboService.listByVo(stoVrfidHistoryVO));
    }

    @GetMapping("/load")
    @ApiOperation(value = "读取单个")
    public ApiResult load(StoVrfidHistoryVO stoVrfidHistoryVO, @CurrentUser LoginInfo loginInfo) throws Exception {
        return ResponseUtil.ok(stoVrfidHistoryDubboService.getById(stoVrfidHistoryVO.getHistoryId()));
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存信息")
    public ApiResult save(@RequestBody StoVrfidHistoryVO stoVrfidHistoryVO, @CurrentUser LoginInfo loginInfo) throws Exception {
        stoVrfidHistoryDubboService.saveOrUpdate(stoVrfidHistoryVO,loginInfo);
        return ResponseUtil.ok("success");
    }

    @PostMapping("/del")
    @ApiOperation(value = "删除")
    public ApiResult del(@RequestBody List<StoVrfidHistoryVO> stoVrfidHistoryVOList) throws Exception {
        stoVrfidHistoryDubboService.removeByListVo(stoVrfidHistoryVOList);
        return ResponseUtil.ok("success");
    }

}
